<?php
/**
 *
 */
namespace Test\modules\News;

use Yz_Module_Interface;

class Model_Default
    extends \Yz_Model_Abstract
{

    const SOURCE_NAME = 'yz_news';


    /** The name of the source used by the model
     *  @var string|null
     */
    protected $sourceName;



    /** Model's constructor requires module
     *  @param Yz_Module_Interface $module
     */
    protected function __construct( Yz_Module_Interface $module )
    {
        debug();
        parent::__construct($module);
        $d =& $this->__dict__;
        $d['id']     = new \Yz_Property_Id();
        $d['date']   = new \Yz_Property_Date();
        $d['title']  = new \Yz_Property_String();
        $d['text']   = new \Yz_Property_Text();
    }

    /**
     *
     *  @param int $id
     *  @return Yz_Item_Interface
     *  @throws NotFound
     */
    public function fetchItemByTitle($title)
    {
        debug();
        $action = $this->selectAction('SelectByTitle');
        $values = $action
            ->setTitle($title)
            ->perform()
            ->fetch()
        ;

        return $this->assignItem($values);
    }


}
